<?php
import('controller.class.php');
import('view.request.class.php');
import('model.request.class.php');
class Request extends Controller{
	var $view = null;

	function __construct(){
		$this->view = new ViewRequest();
	}

	public function action(){
		list($requester,$nickName) = $this->parseJsonArgs();

		$rqstModel = ModelRequest::generateByNick($requester, $nickName);

		if($rqstModel->nickName == null || strlen($rqstModel->nickName) == 0 ){
			parent::displayByCode(REQUEST_F_NICK_NEEDED);
		}else{
			parent::display($this->view->getRequestSuccessView($rqstModel->code));
				
		}
	}

	private function parseJsonArgs(){
		$uuid = $_SESSION['uuid'];
		$nick_name=getArgs('nick','Unkown Name');

		return array($uuid,$nick_name);
	}
}
